package com.bulls.demo.hrmsdemo.ib;

import javax.persistence.EntityManager;

import com.bulls.demo.hrmsdemo.dao.LoginDAO;
import com.bulls.demo.hrmsdemo.dao.LoginDAOImpl;
import com.bulls.demo.hrmsdemo.db.User;


public class LoginLogic {
	
	static LoginDAO loginDAO;
	public static boolean isvalidUser(String userName,String password,EntityManager entityManager){
		boolean boo = false;
		System.out.println("ogic------------>");
		User user = getDAO().fetchUser(userName, entityManager);
		if(user!=null&&user.getPassword()!=null){
			if(user.getPassword().equals(password)){
				boo = true;
			}
		}
		return boo;
	}

	public static LoginDAO getDAO(){
		LoginDAOImpl loginDAOImpl = new LoginDAOImpl();
		loginDAO = loginDAOImpl;
		return loginDAO;
	}
}
